package com.unionfind;

/**
 * PC : path compression
 * @Author: tgy
 * @Date: 2020-10-20 11:41
 */
public class UnionFind_QU_R_PC extends UnionFind_QU_R {

    public UnionFind_QU_R_PC(int capacity) {
        super(capacity);
    }

    @Override
    public int find(int v) {

        checkV(v);

        if (parents[v] != v) {

            parents[v] = find(parents[v]);
        }

        return parents[v];
    }
}
